#include "http_client.h"
#include <iostream>
int main()
{
    HttpClient cli("8.152.4.127", 443); // 注意host不要带https://
    cli.setDefaultHeaders({{"User-Agent", "MyHttpsClient/1.0"},
                           {"Accept", "application/json"},
                           {"Authorization", "Bearer 8XaDhYEgXM9ta6wACcEnLdmA8I6eCHyK2xkjWFKVZ8bVFvkCIS15ewKetQ43r0LA"}});
    cli.enable_server_certificate_verification(false);
    cli.setTimeout(5);
    cli.setFollowRedirect(true);

    // 拼接带Query参数的路径
    std::string path = "/cabinet/records/add";

    // 包含要求的字段
    std::string body = R"({
        "brand_code": "Anke2101",
        "organization": "安科测试一店",
        "zone": "安科测试一店男更",
        "phone": "13533315326", 
        "cabinet_number": "12",
        "cabinet_type": "长租柜",
        "action": "领柜存包",
        "time": "2024-08-20 14:30:00"
    })";

    auto res = cli.post(path, body, "application/json");
    if (res.ok)
    {
        std::cout << "POST 状态码: " << res.status << std::endl;
        std::cout << "POST 响应体: " << res.body << std::endl;
    }
    else
    {
        std::cout << "POST 错误: " << res.error << std::endl;
    }

    return 0;
}
